﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/yahoo-dom-event.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/element-min.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/charts-min.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/datasource-min.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/json.js" type="text/javascript"></script>
    <script src="../scripts/YUI2/swf/swf-min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.ajax({
            url: "../data/system.aspx?method=36",
            async: false,
            success: function (text) {
                if (text == "no")
                    window.location = "../system/error.html";
                else if (text == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                }
            }
        });
    </script>
</head>
<body>
<div id="panel1" class="mini-panel" showToolbar="true" style="width:100%;height:100%" showHeader="false">
    <div property="toolbar">
        <table>
            <tr>
                <td>
                    类别：
                    <input id="type" class="mini-combobox" repeatlayout="table" repeatdirection="vertical" textField="jt_name" valueField="jt_id"
                        style="width: 150px;" url="../data/system.aspx?method=CbxJobTypeP" value="0" required="true" />
                    开始日期：
                    <input id="sdate" class="mini-datepicker"/>
                    结束日期：
                    <input id="edate" class="mini-datepicker"/>
                    <a class="mini-button" iconcls="icon-search" plain="true" onclick="search();">查询</a>
                </td>
            </tr>
        </table>
    </div>
    <div id="chartContainer" style="width:100%;height:100%;"></div>
</div>
    <script type="text/javascript">
        $.ajaxSetup({
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            complete: function (XMLHttpRequest, textStatus) {
                if (XMLHttpRequest.responseText == "out") {
                    top.location = "../login.html";
                }
            }
        });

        mini.parse();

        var myDate = new Date();
        var year = myDate.getFullYear();
        mini.get("sdate").setValue(myDate.getFullYear() + "/" + (myDate.getMonth() + 1) + "/1");
        mini.get("edate").setValue(myDate.getFullYear() + "/" + (myDate.getMonth() + 2) + "/1");
        var chartContainerId = "chartContainer";
        search();

        function search() {
            var type = mini.get("type").getValue();
            var sdate = mini.get("sdate").getText();
            var edate = mini.get("edate").getText();
            if (sdate == '') {
                ShowMessage("系统提示", "请选择开始日期！", 2);
                return;
            }
            if (edate == '') {
                ShowMessage("系统提示", "请选择结束日期！", 2);
                return;
            }
            $.ajax({
                url: "../data/system.aspx?method=SJob",
                data: { type: type, sdate: sdate, edate: edate },
                success: function (text) {
                    var o = mini.decode(text);
                    buildChart(o);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    ShowMessage("系统提示", "页面加载失败！", 3);
                }
            });
        }

        function buildChart(data) {
            YAHOO.widget.Chart.SWFURL = "../scripts/YUI2/swf/charts.swf";
            YAHOO.namespace("demo");
            YAHOO.demo.data = data;
            var DataSource = new YAHOO.util.DataSource(YAHOO.demo.data);
            DataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
            DataSource.responseSchema = { fields: ["job", "total"] };

            var mychart = new YAHOO.widget.PieChart(chartContainerId, DataSource,
	        {
	            dataField: "total",
	            categoryField: "job",
                wmode:"transparent",
	            style:
		        {
		            padding: 0,
		            legend:
			        {
			            display: "bottom",
			            padding: 10,
			            spacing: 5,
			            font:
				        {
				            family: "Arial",
				            size: 12
				        }
			        }
		        }
	        });
        }
    </script>
</body>
</html>